import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';
import 'package:meal/constant/antd_icons.dart';
import 'package:meal/constant/sizes.dart';
import 'package:meal/route/route.dart';
import 'package:meal/utils/colors.dart';
import 'package:meal/utils/styles.dart';
import 'package:meal/utils/tools.dart';

///
/// 开店
///
class OpenStore extends StatefulWidget {
  const OpenStore({Key? key}) : super(key: key);

  @override
  State<OpenStore> createState() => _OpenStoreState();
}

class _OpenStoreState extends State<OpenStore> {
  bool isChecked = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: ToolsUtils.getDefaultBrnAppBar('开店申请'),
      body: Container(
        padding: const EdgeInsets.symmetric(horizontal: Sizes.default20),
        child: Column(
          children: [
            Container(
              margin: const EdgeInsets.only(top: Sizes.default100),
              alignment: Alignment.centerLeft,
              child: Text('商家开店',
                  style: StylesUtils.customTextStyle(
                      color: ColorsUtils.color363, fontSize: Sizes.default30)),
            ),
            Container(
              alignment: Alignment.centerLeft,
              child: Text('未注册的手机号验证通过后自动创建帐号',
                  style: StylesUtils.customTextStyle(
                      color: ColorsUtils.color999, fontSize: Sizes.default13)),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              alignment: Alignment.centerLeft,
              child: Row(
                children: [
                  Container(
                    width: Sizes.default60,
                    alignment: Alignment.centerLeft,
                    child: Text('手机号',
                        style: StylesUtils.customTextStyle(
                            fontSize: Sizes.default15, color: ColorsUtils.color363)),
                  ),
                  Expanded(
                      child: Row(
                    children: [
                      Text.rich(TextSpan(
                          text: '+86',
                          style: StylesUtils.customTextStyle(
                              fontSize: Sizes.default16, color: ColorsUtils.color363))),
                      Expanded(
                          child: Container(
                        margin: const EdgeInsets.only(left: Sizes.default10),
                        child: TextField(
                          style: StylesUtils.customTextStyle(
                              color: ColorsUtils.color363, fontSize: Sizes.default16),
                          decoration: InputDecoration(
                              border: const OutlineInputBorder(
                                borderSide: BorderSide.none,
                              ),
                              isCollapsed: true,
                              filled: true,
                              fillColor: ColorsUtils.rgba(255, 255, 255),
                              contentPadding: const EdgeInsets.symmetric(
                                  horizontal: Sizes.default10, vertical: Sizes.default10),
                              constraints: const BoxConstraints(minHeight: 40),
                              hintText: '请输入手机号',
                              hintStyle: StylesUtils.customTextStyle(
                                  fontSize: Sizes.default15, color: ColorsUtils.colorCcc)),
                          keyboardType: TextInputType.phone,
                          onChanged: (String content) {},
                        ),
                      ))
                    ],
                  ))
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              alignment: Alignment.centerLeft,
              child: Row(
                children: [
                  Container(
                    width: Sizes.default60,
                    alignment: Alignment.centerLeft,
                    child: Text('验证码',
                        style: StylesUtils.customTextStyle(
                            fontSize: Sizes.default15, color: ColorsUtils.color363)),
                  ),
                  Expanded(
                      child: Row(
                    children: [
                      Expanded(
                          child: Container(
                        margin: const EdgeInsets.only(right: Sizes.default10),
                        child: TextField(
                          style: StylesUtils.customTextStyle(
                              color: ColorsUtils.color363, fontSize: Sizes.default16),
                          decoration: InputDecoration(
                              border: const OutlineInputBorder(
                                borderSide: BorderSide.none,
                              ),
                              isCollapsed: true,
                              filled: true,
                              fillColor: ColorsUtils.rgba(255, 255, 255),
                              contentPadding: const EdgeInsets.symmetric(
                                  horizontal: Sizes.default10, vertical: Sizes.default10),
                              constraints: const BoxConstraints(minHeight: 40),
                              hintText: '请输入验证码',
                              hintStyle: StylesUtils.customTextStyle(
                                  fontSize: Sizes.default15, color: ColorsUtils.colorCcc)),
                          keyboardType: TextInputType.phone,
                          onChanged: (String content) {},
                        ),
                      )),
                      Container(
                        width: 100,
                        height: Sizes.default40,
                        decoration: BoxDecoration(
                            border: Border.all(color: ColorsUtils.rgba(255, 110, 83, 1)),
                            borderRadius: const BorderRadius.all(Radius.circular(20))),
                        alignment: Alignment.center,
                        child: Text(
                          '获取验证码',
                          textAlign: TextAlign.center,
                          style: StylesUtils.customTextStyle(color: ColorsUtils.colorFf6),
                        ),
                      )
                    ],
                  )),
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              alignment: Alignment.centerLeft,
              child: Wrap(
                spacing: Sizes.default5,
                crossAxisAlignment: WrapCrossAlignment.center,
                children: [
                  BrnCheckbox(
                    radioIndex: 1,
                    onValueChangedAtIndex: (int index, bool value) {
                      isChecked = value;
                      setState(() {});
                    },
                    isSelected: isChecked,
                    childOnRight: true,
                    mainAxisSize: MainAxisSize.min,
                    child: Text(
                      '我已阅读并同意签署',
                      style: StylesUtils.customTextStyle(
                          fontSize: Sizes.default13, color: ColorsUtils.colorE7e),
                    ),
                  ),
                  InkWell(
                    onTap: () {
                      Get.toNamed(RouteGet.userAboutProtocol);
                    },
                    child: Text('《用户协议》',
                        style: StylesUtils.customTextStyle(
                            color: ColorsUtils.colorFf6, fontSize: Sizes.default13)),
                  ),
                  InkWell(
                    onTap: () {
                      Get.toNamed(RouteGet.userAboutPrivacy);
                    },
                    child: Text('《隐私政策》',
                        style: StylesUtils.customTextStyle(
                            color: ColorsUtils.colorFf6, fontSize: Sizes.default13)),
                  )
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              child: FractionallySizedBox(
                widthFactor: 0.9,
                child: GFButton(
                    onPressed: () {
                      Get.toNamed(RouteGet.storeFlow);
                    },
                    text: '我要开店',
                    textStyle: StylesUtils.customTextStyle(fontSize: Sizes.default16),
                    shape: GFButtonShape.pills,
                    type: GFButtonType.solid,
                    size: GFSize.LARGE,
                    color: ColorsUtils.parseColorFromHexString(
                        isChecked ? ColorsUtils.colorFf6 : ColorsUtils.color666)),
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: Sizes.default20),
              child: InkWell(
                onTap: () {
                  Get.toNamed(RouteGet.userLoginLogin);
                },
                child: Text.rich(TextSpan(
                    text: '已有账号，',
                    style: StylesUtils.customTextStyle(
                        fontSize: Sizes.default15, color: ColorsUtils.color797),
                    children: [
                      TextSpan(
                          text: '去登录>',
                          style: StylesUtils.customTextStyle(
                              fontSize: Sizes.default15, color: ColorsUtils.colorFf6))
                    ])),
              ),
            )
          ],
        ),
      ),
      bottomNavigationBar: SafeArea(
          top: false,
          child: Container(
            padding: const EdgeInsets.only(bottom: Sizes.default50),
            alignment: Alignment.bottomCenter,
            child: InkWell(
              onTap: () {
                Get.toNamed(RouteGet.userPasswordForget);
              },
              child: Text.rich(TextSpan(children: [
                WidgetSpan(
                  child: Icon(
                    AntdIcons.questionCircle,
                    color: ColorsUtils.parseColorFromHexString(ColorsUtils.color797),
                    size: Sizes.default15,
                  ),
                  alignment: PlaceholderAlignment.middle,
                ),
                TextSpan(
                    text: '开店帮助', style: StylesUtils.customTextStyle(color: ColorsUtils.color797))
              ])),
            ),
          )),
      resizeToAvoidBottomInset: false,
      extendBody: true,
      extendBodyBehindAppBar: true,
    );
  }
}
